<script>
import AmountInput from '@/components/amountInput/index'
export default {
    components:{
        AmountInput
    },
    props:{
        isEdit:{
            type:Boolean,
            required:true,
            default(){
                return false
            }
        },
        value:{
            required:true
        },
        placeholder:{
            type:String,
            default:''
        },
        type:{
            type:String,
            default:'text'
        },
        formatter:{
            type:Function,
            default:(value) => value
        }
    },
}
</script>

<template>
    <el-input 
        v-if="isEdit && type === 'text'" 
        :value="value" 
        @input="$emit('input',$event)" 
        :placeholder="placeholder" 
    />

    <el-date-picker
        v-else-if="isEdit && type === 'date'"
        :value="value" 
        @input="$emit('input',$event)" 
        type="date"
        :placeholder="placeholder"
    />

    <AmountInput 
        v-else-if="isEdit && type === 'number'"
        :value="value" 
        @input="$emit('input',$event)" 
        :placeholder="placeholder"
    />
    <span v-else-if="value">{{ formatter(value) }}</span>
    <span v-else>暂无</span>
</template>

<style lang="scss">
</style>